import React from 'react'
import {Button,  Table,Divider, Tag } from "antd";
import {FormattedMessage} from "../../utils/locale";
import styles from './StayList.less';
import classNames from 'classnames';
import './table.css';


const columns = [
  {
    key: '1',
    title: '编号',
    dataIndex: 'device_id',
    defaultSortOrder: 'descend',
    // onFilter: (value, record) => record.name.indexOf(value) === 0,
    sorter: (a, b) => a.device_id - b.device_id,
  }, {
    key: '2',
    title: '地点',
    dataIndex: 'name',
  }, {
    key: '3',
    title: '地址',
    dataIndex: 'address',
  }, {
    key: '4',
    title: '到达时间',
    dataIndex: 'endTime',
    // sorter: (a, b) => a.starttime > b.starttime,
  },
  {
    key: '6',
    title: '停留时间',
    dataIndex: 'stayTime',
    // sorter: (a, b) => a.staytime > b.staytime,
  }, {
    key: '7',
    title: '坐标',
    dataIndex: 'xy',
    render: xy => <span>{xy.join(',')}</span>,
  }
];

class StayList extends React.Component {
  constructor(props) {
    super(props);
    document.body.style.cssText = 'overflow:hidden;';

  }
  componentDidMount() {

  }

  rowEventHandler = (info) => {
    const {infoWindowHandler} = this.props;
    return {
      onClick: (e) => {
        const {xy} = info;
        const position = {lng: xy[0], lat: xy[1]};
        infoWindowHandler(position, info);
      },
    }
  };

  render() {
    const {points, visible, onClose} = this.props;
    console.log(points)



    return (
      <div style={visible ? {transform: 'translateY(0)'} : null} className={styles.wrap}>
        <Button htmlType="button" className={classNames(styles.closeBtn,)} size="small"
                icon={visible ? "down" : "up"} onClick={onClose}>{visible ? '关闭' : '显示'}</Button>
        <div>
          <div className={styles.inner}>
            <div className={classNames(styles.content, 'stay-table-wrap')}>

              <Table size="small" style={{fontSize: 10}} columns={columns} dataSource={points}
                     onRow={this.rowEventHandler}/>
            </div>
          </div>
        </div>
      </div>
    )
  }
}


export default StayList;
